package cn.tedu.hotel.schedule;

import cn.tedu.hotel.service.IRoomService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 更新缓存的计划任务
 *
 * @author java@tedu.cn
 * @version 0.0.1
 */
@Slf4j
@Component
public class CacheSchedule {

    @Autowired
    IRoomService roomService;

    public CacheSchedule(){
        log.debug("创建计划任务对象：CacheSchedule");
    }

    @Scheduled(fixedRate = 5 * 60 * 1000)
    public void updateCache(){
        log.debug("执行了CacheSchedule的计划任务……");
        log.debug("加载房间数据到缓存中");
        roomService.loadRoomToCache();
    }


}
